<?php

elgg_register_event_handler('init', 'system', 'group_tools_priority_init', 999);

function group_tools_priority_init() {

	$views = elgg_get_config('views');
	$tools = $views->extensions['groups/tool_latest'];

	foreach ($tools as $old_priority => $view) {
		elgg_unextend_view('groups/tool_latest', $view);
		$priority = ($new_priority = elgg_get_plugin_setting("tools:$view", 'groups')) ? $new_priority : $old_priority;
		elgg_extend_view('groups/tool_latest', $view, $priority);
	}

	elgg_extend_view('plugins/groups/settings', 'group_tools_priority/settings');

}
